package cn.honglian.basic.dto;

import cn.honglian.basic.util.MD5Utils;
import cn.honglian.basic.util.StrUtils;
import cn.honglian.user.domain.User;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.Date;

@Data
public class WxBuderDto {
 @NotBlank(message = "电话不能为空")
 private String  phone;
 @NotBlank(message = "验证码不能为空")
 private String  verifyCode;

 private String  accessToken;

 private String  openId;
 @NotBlank(message = "类型不能为空")
 private String  type;

 public User getUser(){
  String salt = StrUtils.getComplexRandomString(32);
  String password = MD5Utils.encrypByMd5(salt + "1");
  return User.builder()
          .username(this.phone)
          .email(this.phone)
          .password(password)
          .salt(salt)
          .createtime(new Date())
          .state(0)
          .build();
 }
}
